﻿using System;
using System.ComponentModel;
using Rhizome.QuickStart.Elevator.ViewModel;

namespace Rhizome.QuickStart.Elevator.Console
{
    internal class Program
    {
        private static readonly ElevatorViewModel ViewModel = new ElevatorViewModel();

        [STAThread]
        private static void Main(string[] args)
        {
            Print();
            ViewModel.PropertyChanged += (sender, propertyChangedEventArgs) => Print();
            Help();
            ConsoleKeyInfo v;
            do
            {
                v = System.Console.ReadKey();
                switch (v.KeyChar)
                {
                    case 'd':
						ViewModel.DownChecked = !ViewModel.DownChecked;
                        break;
                    case 'u':
						ViewModel.UpChecked = !ViewModel.UpChecked;
                        break;
                    case 's':
                        ViewModel.InvokeStopClick();
                        break;
                    default:
                        Help();
                        break;
                }
            } while (v.KeyChar != 'x');

        }

        private static void Help()
        {
            System.Console.WriteLine("d = down, u = up, s=stop, x=exit");
        }

        private static void Print()
        {
            System.Console.WriteLine("Position = {0}, IsOpen = {1}", ViewModel.Position, ViewModel.IsOpen);
        }
    }
}